import React from 'react'
import {connect} from 'react-redux'
import {Form, Row, Col, Select, DatePicker, Checkbox, Input, Icon, Spin, message, Popconfirm} from 'antd'
import {messages} from "share/common";
import subsidyService from "containers/expense-report/template/subsidy-service"
import debounce from 'lodash.debounce'
import 'styles/expense-report/subsidy-edit.scss'
import moment from "moment/moment";
import config from 'config';
import Selector from 'components/selector'
const FormItem = Form.Item;
const Option = Select.Option;
const RangePicker = DatePicker.RangePicker;
const CheckboxGroup = Checkbox.Group;
const TextArea = Input.TextArea;
import Skeleton from 'components/skeleton'
import Condition from 'components/condition'
const { If, Else } = Condition;

class SubsidyEditItem extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: false,
      formLoading: false,
      citySelected: {},
      options: [],
      expenseTypeOIDs: [],
      info: {},
      cityList: [],
      dpCityList: [],
      subsidyRules: [],// 拆补规则
      subsidyEnumDTOs: [], // 值列表选中值
      cityCondition: {}
    };
    this.getCityList = debounce(this.getCityList, 500);
  }

  componentDidMount() {
    const { applyData } = this.props;
    this.setState({ info: applyData }, () => {
      if (!applyData.id) {
        this.handleGetSubsidyRules();
      } else {
        this.handleSetSubsidyRules();
      }
    });
    if (applyData.expenseTypes) {
      let result = [];
      applyData.expenseTypes.map(item => {
        result.push({label: item.name, value: item.expenseTypeOID});
      });
      this.setState({ options: result},() => {
        let isAll = true;
        let temp = applyData.expenseTypeOIDs ? JSON.parse(JSON.stringify(applyData.expenseTypeOIDs)) : [];
        this.state.options.map(item => {
          !~temp.indexOf(item.value) && (isAll = false);
        });
        isAll && temp.push('all');
        this.setState({expenseTypeOIDs: temp});
      })
    }
  }

  componentWillReceiveProps(nextProps) {
    if (typeof nextProps.applyData.international === 'boolean') {
      let result = [];
      if (nextProps.applyData.expenseTypes) {
        nextProps.applyData.expenseTypes.map(item => {
          result.push({label: item.name, value: item.expenseTypeOID});
        });
      }
      let { options } = this.state;
      this.setState({info: nextProps.applyData, options: result.length ? result : options}, () => {
        let isAll = true;
        let temp = nextProps.applyData.expenseTypeOIDs ? JSON.parse(JSON.stringify(nextProps.applyData.expenseTypeOIDs)) : [];
        this.state.options.map(item => {
          !~temp.indexOf(item.value) && (isAll = false);
        });
        isAll && temp.push('all');
        this.setState({expenseTypeOIDs: temp});
      });
    } else {
      this.setState({
        info: nextProps.applyData,
        expenseTypeOIDs: [],
        options: [],
        citySelected: {}
      });
    }
  };

  //根据关键字获取城市列表
  getCityList = (isArrival, keyWord) => {
    const { language } = this.props;
    const { info } = this.state;
    let cityListKey = isArrival ? 'cityList' : 'dpCityList';
    let country = info.international ? 'foreign' : 'china';
    if (!isArrival) {
      country = info.dpCityInternational ? 'foreign' : 'china';
    }
    subsidyService.searchCites(keyWord, country, language.code === 'zh_cn' ? 'zh_cn' : 'en_us').then(res => {
      this.setState({
        [cityListKey]: res.data
      })
    })
  };

  //修改城市
  handleCityChange = (isArrival, cityName, opt) => {
    const { info } = this.state;
    let citySelected = opt.props['data-city'];
    let value = [citySelected.adName, citySelected.adCode];
    let type=[];
    //出发城市与差补类型无关
    if (!isArrival) {
      type = ['dpCityName', 'dpCityCode'];
    } else {
      type = ['cityName', 'cityCode'];
      let [cityName, cityCode] = value;
      this.setState({ cityCondition: { cityName, cityCode } }, this.handleSearchTypes);
    }
    this.props.onObjectChange(info, value, type);
    this.setState({ citySelected });
  };

  //获取差补类型
  handleSearchTypes = () => {
    const { getFieldValue } = this.props.form;
    this.handleValidate()
      .then(() => {
        const {
          subsidyExtendID, subsidySelection, expenseReportOID, userDTOList, showExtend, subsidyStartDate, subsidyEndDate
        } = this.props;
        const { info, subsidyEnumDTOs, options } = this.state;
        const { cityCode, cityName } = info;
        let expenseReportSubsidyDTOS = [{
          cityCode, cityName, expenseReportOID, subsidyExtendID,
          subsidyEnumDTOs: subsidyEnumDTOs.length ? subsidyEnumDTOs : info.subsidyEnumDTOs,
          startDate: `${moment(getFieldValue('backToEnd')[0]).utc().format('YYYY-MM-DDTHH:mm')}Z`,
          endDate: `${moment(getFieldValue('backToEnd')[1]).utc().format('YYYY-MM-DDTHH:mm')}Z`,
        }];
        let params = {
          expenseReportSubsidyDTOS,
          subsidyStartDate,
          subsidyEndDate,
          userDTOList,
          expenseReportOID,
          showExtend
        };
        let search = () => {
          if (options[0]) {
            message.warning(messages('expense-parent-report.key216')/*更改后会清空计算当前差补选择*/);
          }
          subsidyService.getExpenseTypes(params)
            .then(res => {
              let result = [];
              let expenseTypes = [];
              if (res.data.expenseTypes) {
                expenseTypes = JSON.parse(JSON.stringify(res.data.expenseTypes));
                res.data.expenseTypes.map(item => {
                  result.push({ label: item.name, value: item.expenseTypeOID });
                });
              }
              this.setState({
                options: result,
                expenseTypeOIDs: [],
                loading: false
              }, () => {
                let value = [expenseTypes, [], res.data.result, res.data.expenseReportSubsidyOID, res.data.formOID];
                let type = ['expenseTypes', 'expenseTypeOIDs', 'result', 'expenseReportSubsidyOID', 'formOID'];
                this.props.onObjectChange(info, value, type);
                subsidySelection && this.setValue(['all']);
              });
            })
            .catch(e => {
              message.error(e.response.data.message);
              this.setState({
                loading: false,
                options: [],
                expenseTypeOIDs: []
              }, () => {
                let value = [[], [], [], '', ''];
                let type = ['expenseTypes', 'expenseTypeOIDs', 'result', 'expenseReportSubsidyOID', 'formOID'];
                this.props.onObjectChange(info, value, type);
              });
            });
        };
        this.setState({ loading: true }, search);
      })
      .catch(() => {

      });
  };

  //修改城市，用于清空城市时的赋值
  handleCityEmpty = (isArrival) => {
    const { info } = this.state;
    let value = [undefined, undefined];
    let type = isArrival ? ['cityName', 'cityCode'] : ['dpCityName', 'dpCityCode'];
    this.props.onObjectChange(info, value, type);
    this.setState({ cityCondition: {} });
  };

  //修改国际／国内
  handleInternationalChange = (isArrival, value) => {
    const { info } = this.state;
    let result = value === 'foreign';
    let type = [];
    if (isArrival) {
      type = ['international', 'cityName', 'cityCode', 'expenseTypes']
    } else {
      type = ['dpCityInternational', 'dpCityName', 'dpCityCode'];
    }
    this.props.form.setFieldsValue({ [isArrival ? 'cityName' : 'dpCityName']: undefined });
    this.props.onObjectChange(info, [result, '', '', []], type);
  };

  setValue = (checkedValues) => {
    const { options, expenseTypeOIDs, info } = this.state;
    let result = ['all'];
    options.map(item => {
      result.push(item.value);
    });
    let isAll =  expenseTypeOIDs ? ~expenseTypeOIDs.indexOf('all') : false;
    let temp = isAll ? [] : (checkedValues.length === options.length ? result : checkedValues);
    let copyCheckedValues = JSON.parse(JSON.stringify(checkedValues));
    let index = copyCheckedValues.indexOf('all');
    if (isAll) {
      copyCheckedValues.splice(index, 1)
    }
    let resultTemp = isAll ? copyCheckedValues : result;
    this.setState({expenseTypeOIDs: ~checkedValues.indexOf('all') ? resultTemp : temp},() => {
      const {expenseTypeOIDs} = this.state;
      let temps = JSON.parse(JSON.stringify(expenseTypeOIDs));
      temps.map((item,index) => {
        item === 'all' && (temps[index] = undefined);
      });
      temps = temps.filter(item => !!item);
      this.props.onObjectChange(info,[temps],['expenseTypeOIDs'])
    });
  };

  handleDelete = () => {
    const {info} = this.state;
    this.props.onDelete(info);
  };

  handleRemarkChange = (e) => {
    const {info} = this.state;
    this.props.onObjectChange(info,[e.target.value],['remark'])
  };

  // 修改出差起止日期
  handleBackToEndChange = (dates) => {
    let { info } = this.state;
    let startDate = dates[0] ? moment(dates[0]).format("YYYY-MM-DD 00:00:00") : null;
    let endDate = dates[1] ? moment(dates[1]).format("YYYY-MM-DD 00:00:00") : null;
    info.startDate = startDate ? moment(startDate).utc() : null;
    info.endDate = endDate ? moment(endDate).utc() : null;
    this.setState({ info }, this.handleSearchTypes);
    this.props.onObjectChange(info, [startDate, endDate], ['startDate','endDate'])
  };

  disabledDate = (value) => {
    let { subsidyStartDate, subsidyEndDate } = this.props;
    if (subsidyStartDate && subsidyEndDate) {
      let startDate = moment(moment(subsidyStartDate).local().format('YYYY-MM-DD 00:00:00'));
      let endDate = moment(moment(subsidyEndDate).local().format('YYYY-MM-DD 23:59:59'));
      return value.valueOf() < startDate.valueOf() || value.valueOf() > endDate.valueOf();
    }
    return false;
  };

  handleAutoExpenseTypes = () => {
    const { getFieldValue } = this.props.form;
    const {
      withCity, expenseReportOID, subsidySelection, applyData, userDTOList, showExtend, subsidyStartDate, subsidyEndDate,
      subsidyExtendID
    } = this.props;
    const { citySelected, info, subsidyEnumDTOs } = this.state;
    if (!withCity) {
      this.setState({ loading: true });
      let expenseReportSubsidyDTOS = [{
        expenseReportOID, subsidyExtendID,
        subsidyEnumDTOs: subsidyEnumDTOs.length ? subsidyEnumDTOs : info.subsidyEnumDTOs,
        startDate: `${moment(getFieldValue('backToEnd')[0]).utc().format('YYYY-MM-DDTHH:mm')}Z`,
        endDate: `${moment(getFieldValue('backToEnd')[1]).utc().format('YYYY-MM-DDTHH:mm')}Z`,
      }];
      let params = {
        expenseReportSubsidyDTOS,
        subsidyStartDate,
        subsidyEndDate,
        userDTOList,
        expenseReportOID,
        showExtend
      };
      subsidyService.getExpenseTypes(params)
        .then(res => {
          let result = [];
          let expenseTypes = [];
          if (res.data.expenseTypes) {
            expenseTypes = JSON.parse(JSON.stringify(res.data.expenseTypes));
            res.data.expenseTypes.map(item => {
              result.push({ label: item.name, value: item.expenseTypeOID });
            });
          }
          this.setState({ options: result, loading: false }, () => {
            let value = [
              citySelected.adName,
              citySelected.adCode,
              expenseTypes,
              [],
              res.data.result,
              res.data.expenseReportSubsidyOID,
              res.data.formOID
            ];
            let type = ['cityName', 'cityCode', 'expenseTypes', 'expenseTypeOIDs', 'result', 'expenseReportSubsidyOID', 'formOID'];
            this.props.onObjectChange(applyData, value, type);
            subsidySelection && this.setValue(['all']);
          });
        })
        .catch(e => {
          message.error(e.response.data.message);
          this.setState({ loading: false });
        });
    }
  };

  handleGetSubsidyRules = () => {
    let { subsidyRules, info } = this.state;
    const { formOID, applyData } = this.props;
    let subsidyEnumDTOs = info.subsidyEnumDTOs || [];
    this.setState({ formLoading: true });
    subsidyService.getSubsidyRules({ formOID })
      .then(res => {
        this.setState({ formLoading: false });
        let { data } = res;
        //没有值列表
        if (!data[0]) {
          // 新建的小行程才需要重新获取差补，编辑的不需要
          !applyData.showCancelEdit && this.handleAutoExpenseTypes();
          return;
        }
        subsidyEnumDTOs.map(item => {
          data.some(rule => {
            if (rule.enumerationOID === item.enumerationOID) {
              rule.enumerationItemShowValue = item.enumerationItemShowValue;
              return true;
            }
          });
        });
        subsidyRules.push(...data);
        //新建的小行程值列表有默认值时，可以直接获取差补信息
        if (!subsidyEnumDTOs.length) {
          subsidyRules.map(item => {
            //值列表有默认值
            item.enumerationItemValue && subsidyEnumDTOs.push(item);
          });
          info.subsidyEnumDTOs = subsidyEnumDTOs;
          this.setState({ subsidyEnumDTOs, info }, this.handleSearchTypes)
        }
        this.setState({ subsidyRules, subsidyEnumDTOs });
      })
      .catch(() => {
        this.setState({ formLoading: false });
        // 新建的小行程才需要重新获取差补，编辑的不需要
        !applyData.showCancelEdit && this.handleAutoExpenseTypes();
      });
  };

  handleSetSubsidyRules = () => {
    let { subsidyRules, info } = this.state;
    let { subsidyEnumDTOs } = info;
    if (subsidyEnumDTOs && subsidyEnumDTOs[0]) {
      subsidyRules.push(...subsidyEnumDTOs);
    }
    this.setState({ subsidyRules, subsidyEnumDTOs: subsidyEnumDTOs || [] });
  };

  // 修改差补值列表的值
  handleSubsidyRules = (result, option, rule) => { // 同步状态
    let { info } = this.state;
    let { subsidyEnumDTOs } = info;
    let pushFnc = () => {
      subsidyEnumDTOs.push({
        'enumerationItemShowValue': result.messageKey,
        'enumerationOID': result.customEnumerationOID,
        'enumerationName': rule.enumerationName,
        'enumerationItemValue': result.value,
      });
    };
    if (subsidyEnumDTOs && subsidyEnumDTOs[0]) {
      const isSave = subsidyEnumDTOs.some((item, index) => {
        if (item.enumerationOID === rule.enumerationOID) {
          if (result) {
            item.enumerationItemShowValue = result.messageKey;
            item.enumerationItemValue = result.value;
          } else {
            subsidyEnumDTOs.splice(index, 1);
          }
          return true;
        }
      });
      if (!isSave && result) {
        pushFnc();
      }
    } else {
      subsidyEnumDTOs = [];
      if (result) {
        pushFnc();
      }
    }
    this.setState({ subsidyEnumDTOs }, this.handleSearchTypes);
    this.props.onObjectChange(info, [subsidyEnumDTOs], ['subsidyEnumDTOs']);
  };

  handleValidate = () => {
    const { withCity } = this.props;
    const { info, subsidyRules, subsidyEnumDTOs } = this.state;
    const checkRules = subsidyRules.length === subsidyEnumDTOs.length;
    return new Promise((resolve, reject) => {
      if (info.startDate && info.endDate && (info.cityCode || !withCity)) {
        checkRules ? resolve(true) : reject(false);
      } else {
        reject(false);
      }
    });
  };

  /**
   * 渲染出发／到达城市
   * @param isArrival true:到达城市 false:出发城市
   * @returns {XML}
   */
  renderCityItem = (isArrival) => {
    const { isAutoCalculateEnabled } = this.props;
    const { info, cityList, dpCityList } = this.state;
    const { getFieldDecorator } = this.props.form;
    let internationalKey = isArrival ? 'international' : 'dpCityInternational';
    let cityNameKey = isArrival ? 'cityName' : 'dpCityName';
    let cityOptions = isArrival ? cityList : dpCityList;
    let itemLabel = messages('expense-parent-report.key186')/*出差城市*/;
    if (isAutoCalculateEnabled) {
      itemLabel = isArrival ? messages('expense-parent-report.key187')/*到达城市*/ : messages('expense-parent-report.key188')/*出发城市*/
    }
    return (
      <Row>
        <Col span={13}>
          <FormItem label={itemLabel}
                    labelCol={{span: 15}}
                    wrapperCol={{span: 9}}>
            {getFieldDecorator(internationalKey, {
              rules: [{
                required: !!isArrival
              }],
              initialValue: typeof info[internationalKey] === 'boolean'? (info[internationalKey] ? 'foreign' : 'china') : undefined
            })(
              <Select onChange={value => this.handleInternationalChange(isArrival, value)}>
                <Option key="china">{messages('expense-parent-report.key75'/*国内*/)}</Option>
                <Option key="foreign">{messages('expense-parent-report.key76'/*国际*/)}</Option>
              </Select>
            )}
          </FormItem>
        </Col>
        <Col span={10} offset={1}>
          <FormItem>
            {getFieldDecorator(cityNameKey, {
              rules: [{
                required: !!isArrival,
                message: messages('common.can.not.be.empty', {name: messages('expense-parent-report.key189')/*城市*/})
              }],
              initialValue: info[cityNameKey] ? info[cityNameKey] : undefined
            })(
              <Select mode="combobox"
                      placeholder={messages('expense-parent-report.key77'/*城市名*/)}
                      showArrow={false}
                      onSelect={(value, opt) => this.handleCityChange(isArrival, value, opt)}
                      filterOption={false}
                      allowClear
                      optionLabelProp="title"
                      getPopupContainer={triggerNode => triggerNode.parentNode}
                      onChange={value => !value && this.handleCityEmpty(isArrival)}
                      onSearch={value => this.getCityList(isArrival, value)}>
                {cityOptions.map(city => {
                  return (
                    <Option data-city={city} key={city.adCode} title={city.adName}>
                      <Condition>
                        <If value={city.countryName}>
                          {city.adName}&nbsp;&nbsp;<span style={{color: '#ccc'}}>({city.countryName})</span>
                        </If>
                        <Else>
                          {city.adName}
                        </Else>
                      </Condition>
                    </Option>
                  )
                })}
              </Select>
            )}
          </FormItem>
        </Col>
      </Row>
    )
  };

  // 渲染操作部分
  renderOperate = () => {
    const { applyData, dataList, onCancelEdit } = this.props;
    return (
      <div className="header-operate">
        <If value={applyData.showCancelEdit}>
          <a onClick={() => onCancelEdit(applyData)}>{messages('expense-parent-report.key239')/*取消编辑*/}</a>
        </If>
        <If value={applyData.showCancelEdit && dataList.length > 1}>
          <span className="ant-divider"/>
        </If>
        <If value={dataList.length > 1}>
          <Popconfirm
            placement="topRight"
            title={messages('common.confirm.delete')/*确定要删除吗？*/}
            getPopupContainer={() => document.getElementsByClassName('header-operate')[0]}
            onConfirm={this.handleDelete}
          >
            <a className="delete">{messages('common.delete')/*删除*/}</a>
          </Popconfirm>
        </If>
      </div>
    )
  };

  render() {
    const { formLoading, options, expenseTypeOIDs, info, loading, subsidyRules } = this.state;
    const { withCity, isAutoCalculateEnabled, subsidyIndex } = this.props;
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 4 },
      wrapperCol: { span: 20 }
    };
    return (
      <div className='subsidy-form'>
        <div className="info-header">
          {messages('expense-parent-report.key240',{arg1: subsidyIndex})/*行程{arg1}*/}
          {this.renderOperate()}
        </div>
        <Skeleton loading={formLoading}>
          <Form className="info-form">
            <Row>
              <If value={withCity || info.cityName}>
                <If value={isAutoCalculateEnabled}>
                  <Col span={12}>
                    {this.renderCityItem()}
                  </Col>
                </If>
                <Col span={12}>
                  {this.renderCityItem(true)}
                </Col>
              </If>
              <Col span={12}>
                <FormItem
                  labelCol={{ span: 8 }}
                  wrapperCol={{ span: 16 }}
                  label={messages('expense-parent-report.key241')/*行程日期*/}>
                  {getFieldDecorator('backToEnd', {
                    rules: [{
                      required: true,
                      message: messages('common.can.not.be.empty', { name: messages('expense-parent-report.key241')/*行程日期*/ })
                    }],
                    initialValue: (
                      (info.startDate && info.endDate) ?
                        [moment(moment(info.startDate)
                          .local(), 'YYYY-MM-DD'), moment(moment(info.endDate)
                          .local(), 'YYYY-MM-DD')] : undefined
                    )
                  })(
                    <RangePicker
                      format={'YYYY-MM-DD'}
                      disabledDate={this.disabledDate}
                      onChange={this.handleBackToEndChange}
                    />
                  )}
                </FormItem>
              </Col>
              {subsidyRules[0] &&
              subsidyRules.map(item => {
                item.selectorItem = {
                  url: `${config.baseUrl}/api/custom/enumerations/${item.enumerationOID}/items/v2`,
                  label: 'messageKey',
                  key: 'value',
                  searchKey: 'keyword'
                };
                return (<Col span={12}>
                  <FormItem
                    label={item.enumerationName}
                    labelCol={{ span: 8 }}
                    wrapperCol={{ span: 16 }}>
                    {getFieldDecorator(item.enumerationOID, {
                      rules: [{
                        required: true,
                        message: messages('expense-parent-report.key217',{arg1:item.enumerationName})/*请输入{arg1}*/
                      }],
                      initialValue: item.enumerationItemShowValue || void 0
                    })(
                      <Selector
                        entity
                        searchIfKeywordIsNull
                        selectorItem={item.selectorItem}
                        params={{ page: 0, size: 20 }}
                        allowClear={false}
                        onChange={(result, option) => this.handleSubsidyRules(result, option, item)}
                        getPopupContainer={triggerNode => triggerNode.parentNode}
                        placeholder={item.enumerationName}/>
                    )}
                  </FormItem>
                </Col>);
              })
              }
            </Row>
            <Row>
              <FormItem {...formItemLayout} label={messages('expense-parent-report.key43'/*差补类型*/)}>
                {getFieldDecorator('expenseTypes', {
                  rules: [{
                    required: true
                  }],
                })(
                  <Spin spinning={loading}>
                    <div>
                      {options.length > 0 ? (
                        <CheckboxGroup value={expenseTypeOIDs} onChange={this.setValue}>
                          <Row>
                            <Checkbox value="all" key="all">{messages('expense-parent-report.key81'/*全选*/)}</Checkbox>
                          </Row>
                          {options.map(item =>
                            <Checkbox key={item.value} value={item.value} className="subsidy-type-option">{item.label}</Checkbox>
                          )}
                        </CheckboxGroup>
                      ) : (
                        <div className="no-expense-type-tip">
                          {withCity
                            ? messages('expense-parent-report.key82'/*当前城市无合适差补类型*/)
                            : messages('expense-parent-report.key157')/*无匹配差补类型*/}
                        </div>
                      )}
                    </div>
                  </Spin>
                )}
              </FormItem>
            </Row>
            <Row>
              <Col span={16}>
                <FormItem
                  label={messages('expense-parent-report.key83'/*备注:*/)}
                  labelCol={{ span: 6 }}
                  wrapperCol={{ span: 18 }}>
                  {getFieldDecorator('remark', {
                    rules: [{
                      max: 200,
                      message: messages('common.max.characters.length', { max: 200 })
                    }],
                    initialValue: info.remark ? info.remark : undefined
                  })(
                    <TextArea onChange={this.handleRemarkChange}/>
                  )}
                </FormItem>
              </Col>
            </Row>
          </Form>
        </Skeleton>
      </div>
    );
  }
}

SubsidyEditItem.propTypes = {
  subsidyIndex: React.PropTypes.number, //行程的序号，从1开始
  applyData: React.PropTypes.object.isRequired,
  expenseReportOID: React.PropTypes.string,
  subsidyStartDate: React.PropTypes.any,
  subsidyEndDate: React.PropTypes.any,
  subsidyExtendID: React.PropTypes.string,
  subsidySelection: React.PropTypes.bool,
  withCity: React.PropTypes.bool,
  isAutoCalculateEnabled: React.PropTypes.bool,
  formOID: React.PropTypes.string,
  dataList: React.PropTypes.array,
  showExtend: React.PropTypes.bool,
  userDTOList: React.PropTypes.array,
  onDelete: React.PropTypes.func,  //删除
  onObjectChange: React.PropTypes.func, //数据改动
  onCancelEdit: React.PropTypes.func, //取消编辑
};

SubsidyEditItem.defaultProps = {
  onDelete: () => {},
  onObjectChange: () => {},
  subsidySelection: false,
  withCity: true
};

function mapStateToProps(state) {
  return {
    language: state.main.language
  }
}

const wrappedSubsidyEditItem = Form.create()(SubsidyEditItem);
export default connect(mapStateToProps)(wrappedSubsidyEditItem);
